<%= assembly_page_header(@assembly, 'operations') %>

<%= component_kind = @component.ciClassName.split('.').last
    breadcrumb [{:icon  => 'operations',
                 :label => @assembly.ciName,
                 :kind  => 'operations',
                 :link  => assembly_operations_path(@assembly)},
                {:icon  => breadcrumb_environment_icon,
                 :label => breadcrumb_environment_label,
                 :kind  => 'Environment',
                 :link  => assembly_operations_environment_path(@assembly, @environment)},
                {:icon  => platform_image_url(@platform),
                 :label => breadcrumb_platform_label,
                 :kind  => 'Platform',
                 :link  => assembly_operations_environment_platform_path(@assembly, @environment, @platform)},
                {:icon  => ci_image_url(@component),
                 :label => @component.ciName,
                 :kind  => component_kind,
                 :link  => assembly_operations_environment_platform_component_path(@assembly, @environment, @platform, @component)}] %>

<%= page_title :page_icon     => ci_image_url(@component),
               :page_kind     => "#{component_kind} Instance",
               :page_label    => @instance.ciName,
               :page_sublabel => "created by #{@instance.createdBy}" %>

<% managed_via = @from_relations.select { |r| r.relationName == 'bom.ManagedVia' }.first
   primary     = @deployed_to.relationAttributes.priority == '1'

   info = ''
   if @deployed_to
     cloud = @deployed_to.toCi
     info += "deployed to #{cloud_marker(cloud, primary, @consumes && @consumes.relationAttributes.adminstatus)}"
   end

   if managed_via.present?
     managed_via_ci = managed_via.toCi
     info += " | managed via #{link_to(highlight(managed_via_ci.ciName), assembly_operations_environment_platform_instance_path(@assembly, @environment, @platform, managed_via_ci))}"
   else
     managed_via_ci = @instance
   end

   ip = managed_via_ci.ciAttributes.attributes[:private_ip] || managed_via_ci.ciAttributes.attributes[:public_ip]
   info += " <small class='text-black'><span>#{ip}</span> <i class='fa fa-files-o'></i></small>" if ip.present?
 %>
<%= page_info info %>

<%= render 'base/shared/page_nav_pages', :items => [{:label => 'summary',       :template => 'summary', :selected => true},
                                                    {:label => 'configuration', :template => 'configuration'},
                                                    {:label => 'monitors',      :url => assembly_operations_environment_platform_component_instance_monitors_path(@assembly, @environment, @platform, @component, @instance)},
                                                    {:label => 'notifications', :url => notifications_assembly_operations_environment_platform_component_instance_path(@assembly, @environment, @platform, @component, @instance)},
                                                    {:label => 'procedures',    :template => 'operations/procedures/procedures'},
                                                    {:label => 'logs',          :url => logs_assembly_operations_environment_platform_component_instance_path(@assembly, @environment, @platform, @component, @instance), :reload => true}] %>
<script>
  copyToClipboard($j('#page_info i.fa-files-o')[0],
                  function() {
                    return $j('#page_info i.fa-files-o').siblings('span')[0];
                  });
</script>
